package interfacesSIAB;


import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Rectangle;
import javax.swing.BorderFactory;
import java.awt.Color;
import javax.swing.border.TitledBorder;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JButton;

import administrador.gestion_de_clientes;
import administrador.gestion_de_proveedores;

public class RetirarProveedor extends JFrame {

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JPanel jPanel = null;
	private JLabel jLabel = null;
	private JTextField codigoProveedor = null;
	private JButton retirar = null;
	private JButton cancelar = null;

	/**
	 * This is the default constructor
	 */
	public RetirarProveedor() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(300, 326);
		this.setResizable(false);
		this.setContentPane(getJContentPane());
		this.setTitle("Retirar Proveedor");
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getJPanel(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel() {
		if (jPanel == null) {
			jLabel = new JLabel();
			jLabel.setBounds(new Rectangle(23, 60, 207, 26));
			jLabel.setText("       Ingresar Codigo de la Empresa");
			jPanel = new JPanel();
			jPanel.setLayout(null);
			jPanel.setBounds(new Rectangle(17, 26, 245, 230));
			jPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.orange), "Proveedor", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
			jPanel.add(jLabel, null);
			jPanel.add(getCodigoProveedor(), null);
			jPanel.add(getRetirar(), null);
			jPanel.add(getCancelar(), null);
		}
		return jPanel;
	}

	/**
	 * This method initializes codigoProveedor	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getCodigoProveedor() {
		if (codigoProveedor == null) {
			codigoProveedor = new JTextField();
			codigoProveedor.setBounds(new Rectangle(50, 112, 127, 20));
		}
		return codigoProveedor;
	}

	/**
	 * This method initializes retirar	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getRetirar() {
		if (retirar == null) {
			retirar = new JButton();
			retirar.setBounds(new Rectangle(10, 168, 99, 24));
			retirar.setText("Retirar");
			retirar.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
				
					try {
						if(getCodigoProveedor().getText().trim().length() > 0 )
						
						{
							gestion_de_proveedores eliminar = new gestion_de_proveedores();
							eliminar.eliminarProveedor(Integer.parseInt(getCodigoProveedor().getText()));
							getCodigoProveedor().setText("");
						}
						else{
							
							JOptionPane.showMessageDialog(null,"Por favor Debe de Ingresar la Cedula");
						}
						}
						catch (Exception e1) {
							JOptionPane.showMessageDialog(null,"El siguiente campo no puede contener caracteres"+ e1.getMessage() );
						    e1.printStackTrace();
						}
						
				
				
				}
			});
		}
		return retirar;
	}

	/**
	 * This method initializes cancelar	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getCancelar() {
		if (cancelar == null) {
			cancelar = new JButton();
			cancelar.setBounds(new Rectangle(120, 169, 98, 24));
			cancelar.setText("Salir");
			
			
cancelar.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {
					
					dispose();
				}
			});
			
			
			
			
			
			
			
			
			
		}
		return cancelar;
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"
